//
//  XLSchedulePresenter.m
//  industry
//
//  Created by xl on 2020/12/18.
//  Copyright © 2020 Haier. All rights reserved.
//

#import "XLSchedulePresenter.h"
#import "XLApproveModel.h"
#import "XLScheduleViewProtocol.h"
#import "XLScheduleInteractorProtocol.h"

@implementation XLSchedulePresenter



//XLApproveMessagesUrl

- (void)requestApproveList:(NSInteger)type page:(NSInteger)page searchStr:(NSString *)str {
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setValue:@(type) forKey:@"approveStatus"];// 0-待办 1-已审批
    [params setValue:@(page) forKey:@"pageNum"];
    [params setValue:@(XLPageSize) forKey:@"pageSize"];
    [params setValue:str forKey:@"param"];
    
    XLHttpRequest *request = [[XLHttpRequest alloc] init];
    WEAKSELF
    [request requestWithMethod:XLHttpMedthTypeGET url:XLApproveMessagesUrl params:params isExtraParams:NO successBlock:^(NSDictionary *dict) {
        STRONGSELF
        id data = [dict objectForKey:@"data"];
        if ([data isKindOfClass:[NSDictionary class]]) {
            id temData = [(NSDictionary *)data objectForKey:@"records"];
            if ([temData isKindOfClass:[NSArray class]]) {
                
                NSArray *temArr = [XLApproveModel mj_objectArrayWithKeyValuesArray:temData];
                XLSend(strongSelf.baseController.cView, XLScheduleViewProtocol, refreshTableView:temArr noData:(temArr.count < XLPageSize) ? YES:NO);
            } else {
                XLSend(strongSelf.baseController.cView, XLScheduleViewProtocol, requestServerError:nil networkReachabilityStatus:XLNetworkReachabilityStatusUnkonw);
            }
        } else {
            XLSend(strongSelf.baseController.cView, XLScheduleViewProtocol, requestServerError:nil networkReachabilityStatus:XLNetworkReachabilityStatusUnkonw);
        }
        
    } failBlock:^(XLServerRequestsStatus status, XLNetworkReachabilityStatus reachability, NSError *error, NSDictionary *dict) {
        STRONGSELF
        XLSend(strongSelf.baseController.cView, XLScheduleViewProtocol, requestServerError:error networkReachabilityStatus:reachability);
    }];
}

- (void)handleCellData:(id)cellData {
    XLSend(self.baseController.interactor, XLScheduleInteractorProtocol, gotoScheduleDTVC:cellData);
}

@end
